package chapter05

object Test02_FunctionDefine {
  def main(args: Array[String]): Unit = {
    //（1）函数 1：无参，无返回值
    def f1(): Unit = println("1. 无参无返回值")

    println(f1())
    println("==================================")

    //（2）函数 2：无参，有返回值
    def f2(): String = "2.无参，有返回值"

    println(f2())
    println("==================================")

    //（3）函数 3：有参，无返回值
    def f3(name: String): Unit = println("Hello " + name)

    println(f3("bob"))
    println("==================================")

    //（4）函数 4：有参，有返回值
    def f4(name: String): String = "Hello " + name

    println(f4("bob"))
    println("==================================")

    //（5）函数 5：多参，无返回值
    def f5(name: String, age: Int): Unit = println("Hello " + name + "age is " + age)

    println(f5("bob", 12))
    println("==================================")

    //（6）函数 6：多参，有返回值
    def f6(name: String, age: Int): String = "Hello " + name + "age is " + age

    println(f6("bob", 12))
    println("==================================")
  }

}
